import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        redirect: '/home',
        component: () => import('@/views/main.vue'),
        children: [
            {
                path: '/home',
                component: () => import('@/views/home.vue'),
            },
            {
                path: '/user',
                component: () => import('@/views/user.vue'),
            },
            {
                path: '/system',
                component: () => import('@/views/system.vue'),
            },
            {
                path: '/other',
                component: () => import('@/views/other/index.vue'),
            },
            {
                path: '/other2',
                component: () => import('@/views/other/other.vue'),
            }
        ]
    }
]

// 避免重复点击相同路由控制台报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
	mode: "history",
    // mode: "hash",
	routes
})

export default router